<template>

  <div id="app">
    <router-view/>
    <div id="nav">
<!--      {{ $route.path }}-->
      <Footer
          v-if="
      $route.path=='/'||
      $route.path.match('/home')||
      $route.path=='/video'||
      $route.path=='/minivideo'
      "
      ></Footer>
    </div>
    <div class="top" v-if="topType" @click="goTop">返回顶部</div>
  </div>
</template>

<script>
//引入Footer Header的组件
import Footer from "./components/Footer.vue";

export default {
  name: "App",
  data(){
    return{
      topType:false,
      scrollTop:"",
    };
  },
  components: {
    Footer,
  },
  mounted() {
    console.log(this.$route.path);
    window.addEventListener("scroll",this.handleScroll);
  },
  deactivated() {
    window.removeEventListener("scroll",this.handleScroll);
  },
  watch:{
    scrollTop(){
      if (this.scrollTop()>=300){
        this.topType=true;
      }else {
        this.topType=false;
      }
    },
  },
  methods:{
    handleScroll(){
      this.scrollTop=
          document.documentElement.scrollTop||document.body.scrollTop;
      if (this.scrollTop>=300){
        this.topType=true;
      }
    },
    goTop(){
      document.documentElement.scrollTop=0;
      document.body.scrollTop=0;
    },
  },
};
</script>

<style>
* {
  padding: 0;
  margin: 0;
}

a {
  text-decoration: none;
}

ul, li {
  list-style: none;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

#nav a.router-link-active {
  color: #f03d37;
}

.top {
  position: fixed;
  right: 0;
  bottom: 2.4rem;
  width: 2.2rem;
  height: 1rem;
  line-height: 1rem;
  z-index: 10;
  opacity: 0.94;
  background-image: linear-gradient(134deg, #fb3333, #ff5269 75%);
  box-shadow: 0 2px 4px 0 rgb(160 44 41 / 15%);
  border-radius: 20px 0 0 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 14px;
}
</style>
